/*     */ package dm.jdbc.innerData;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.CnvtInfo;
/*     */ import dm.jdbc.dataConvertion.JType2CType;
/*     */ import dm.jdbc.desc.ParameterDesc;
/*     */ import dm.jdbc.driver.DmdbStatement_bs;
/*     */ import dm.sql.DmdbIntervalDT;
/*     */ import dm.sql.DmdbIntervalYM;
/*     */ import dm.sql.DmdbTime;
/*     */ import dm.sql.DmdbTimeZone;
/*     */ import java.math.BigDecimal;
/*     */ import java.sql.SQLException;
/*     */ import java.sql.Time;
/*     */ import java.sql.Timestamp;
/*     */ 
/*     */ public class DmdbParamVal implements Cloneable
/*     */ {
/*  18 */   private Object m_readerOrInputStream = null;
/*  19 */   private boolean m_streamConverted = false;
/*  20 */   private int m_offset = 0;
/*  21 */   private boolean m_isReaderOver = false;
/*     */   
/*  23 */   private long m_length = 0L;
/*  24 */   private boolean m_hasLength = false;
/*  25 */   private long m_lengthTmp = 0L;
/*  26 */   private boolean m_hasCalcLenTmp = false;
/*     */   
/*  28 */   private byte m_typeFlag = 0;
/*  29 */   private boolean m_hasTypeFlag = false;
/*     */   
/*  31 */   private int m_targetScale = 0;
/*  32 */   private boolean m_hasTargetScale = false;
/*     */   
/*  34 */   private int m_targetType = 0;
/*  35 */   private boolean m_hasTargetType = false;
/*     */   
/*  37 */   private int m_registerType = 0;
/*  38 */   private boolean m_hasRegisterType = false;
/*     */   
/*  40 */   private int m_registerScale = 0;
/*  41 */   private boolean m_hasRegisterScale = false;
/*     */   
/*  43 */   private boolean m_inData_Bound = false;
/*  44 */   private boolean m_outData_Bound = false;
/*     */   
/*  46 */   int m_putLobData = 1;
/*     */   
/*  48 */   private Object m_val = null;
/*  49 */   private int m_jIOType = -1;
/*     */   
/*  51 */   private DmdbStatement_bs m_stmt = null;
/*     */   
/*  53 */   private boolean m_isNull = false;
/*     */   
/*     */ 
/*  56 */   private byte[] m_bsValueTemp = null;
/*     */   
/*     */   public int hashCode() {
/*  59 */     if (this.m_val == null) {
/*  60 */       return 0;
/*     */     }
/*  62 */     return this.m_val.hashCode() ^ new Integer(this.m_jIOType).hashCode();
/*     */   }
/*     */   
/*     */   public boolean equals(Object o) {
/*  66 */     if (o == null) {
/*  67 */       return false;
/*     */     }
/*  69 */     if (!(o instanceof DmdbParamVal)) {
/*  70 */       return false;
/*     */     }
/*  72 */     DmdbParamVal paramVal = (DmdbParamVal)o;
/*     */     
/*  74 */     if (((this.m_isNull) && (this.m_isNull == paramVal.isNull())) || (
/*  75 */       (this.m_val == null) && (paramVal.getObjVal() == null))) {
/*  76 */       return true;
/*     */     }
/*     */     
/*  79 */     if ((this.m_jIOType == paramVal.getObjType()) && 
/*  80 */       (this.m_jIOType == -1)) {
/*  81 */       return true;
/*     */     }
/*     */     
/*  84 */     Object val = paramVal.getObjVal();
/*  85 */     if ((((this.m_val instanceof Boolean)) && ((val instanceof Boolean))) || 
/*  86 */       (((this.m_val instanceof Byte)) && ((val instanceof Byte))) || 
/*  87 */       (((this.m_val instanceof Integer)) && ((val instanceof Integer))) || 
/*  88 */       (((this.m_val instanceof Long)) && ((val instanceof Long))) || 
/*  89 */       (((this.m_val instanceof Float)) && ((val instanceof Float))) || 
/*  90 */       (((this.m_val instanceof Double)) && ((val instanceof Double))) || 
/*  91 */       (((this.m_val instanceof BigDecimal)) && ((val instanceof BigDecimal))) || (
/*  92 */       ((this.m_val instanceof String)) && ((val instanceof String)))) {
/*  93 */       if (String.valueOf(this.m_val).equals(String.valueOf(val))) {
/*  94 */         return true;
/*     */       }
/*  96 */       return false; }
/*  97 */     if (((this.m_val instanceof java.sql.Date)) && 
/*  98 */       ((val instanceof java.sql.Date))) {
/*  99 */       if (((java.sql.Date)this.m_val).equals((java.sql.Date)val)) {
/* 100 */         return true;
/*     */       }
/* 102 */       return false; }
/* 103 */     if (((this.m_val instanceof Time)) && 
/* 104 */       ((val instanceof Time))) {
/* 105 */       if (((Time)this.m_val).equals((Time)val)) {
/* 106 */         return true;
/*     */       }
/* 108 */       return false; }
/* 109 */     if (((this.m_val instanceof Timestamp)) && 
/* 110 */       ((val instanceof Timestamp))) {
/* 111 */       if (((Timestamp)this.m_val).equals((Timestamp)val)) {
/* 112 */         return true;
/*     */       }
/* 114 */       return false; }
/* 115 */     if (((this.m_val instanceof java.util.Date)) && 
/* 116 */       ((val instanceof java.util.Date))) {
/* 117 */       java.util.Date udt1 = (java.util.Date)val;
/* 118 */       java.util.Date udt2 = (java.util.Date)this.m_val;
/* 119 */       if (udt1.equals(udt2)) {
/* 120 */         return true;
/*     */       }
/* 122 */       return false; }
/* 123 */     if (((this.m_val instanceof DmdbTime)) && ((val instanceof DmdbTime))) {
/* 124 */       DmdbTime t1 = (DmdbTime)this.m_val;
/* 125 */       DmdbTime t2 = (DmdbTime)val;
/* 126 */       if (t1.equals(t2)) {
/* 127 */         return true;
/*     */       }
/* 129 */       return false; }
/* 130 */     if (((this.m_val instanceof DmdbIntervalDT)) && 
/* 131 */       ((val instanceof DmdbIntervalDT))) {
/* 132 */       DmdbIntervalDT dt1 = (DmdbIntervalDT)this.m_val;
/* 133 */       DmdbIntervalDT dt2 = (DmdbIntervalDT)val;
/* 134 */       if (dt1.equals(dt2)) {
/* 135 */         return true;
/*     */       }
/* 137 */       return false; }
/* 138 */     if (((this.m_val instanceof DmdbIntervalYM)) && 
/* 139 */       ((val instanceof DmdbIntervalYM))) {
/* 140 */       DmdbIntervalYM ym1 = (DmdbIntervalYM)this.m_val;
/* 141 */       DmdbIntervalYM ym2 = (DmdbIntervalYM)val;
/* 142 */       if (ym1.equals(ym2)) {
/* 143 */         return true;
/*     */       }
/* 145 */       return false; }
/* 146 */     if (((this.m_val instanceof DmdbTimeZone)) && ((val instanceof DmdbTimeZone))) {
/* 147 */       DmdbTimeZone tz1 = (DmdbTimeZone)this.m_val;
/* 148 */       DmdbTimeZone tz2 = (DmdbTimeZone)val;
/* 149 */       if (tz1.equals(tz2)) {
/* 150 */         return true;
/*     */       }
/* 152 */       return false; }
/* 153 */     if (((this.m_val instanceof byte[])) && ((val instanceof byte[]))) {
/* 154 */       int len1 = ((byte[])this.m_val).length;
/* 155 */       int len2 = ((byte[])val).length;
/* 156 */       if (len1 != len2) {
/* 157 */         return false;
/*     */       }
/* 159 */       for (int i = 0; i < len1; i++) {
/* 160 */         if (((byte[])this.m_val)[i] != ((byte[])val)[i])
/* 161 */           return false;
/*     */       }
/* 163 */       return true;
/*     */     }
/*     */     
/* 166 */     return false;
/*     */   }
/*     */   
/*     */   public void setBsValueTemp(byte[] temp) {
/* 170 */     if (temp == null) {
/* 171 */       return;
/*     */     }
/* 173 */     this.m_bsValueTemp = new byte[temp.length];
/* 174 */     System.arraycopy(temp, 0, this.m_bsValueTemp, 0, this.m_bsValueTemp.length);
/*     */   }
/*     */   
/*     */   public void setStmt(DmdbStatement_bs stmt) {
/* 178 */     this.m_stmt = stmt;
/*     */   }
/*     */   
/*     */   public DmdbStatement_bs getStmt() {
/* 182 */     return this.m_stmt;
/*     */   }
/*     */   
/*     */   private void setObjData(Object jVal, int jType) {
/* 186 */     this.m_val = jVal;
/* 187 */     this.m_jIOType = jType;
/*     */     
/* 189 */     this.m_isNull = (this.m_val == null);
/*     */   }
/*     */   
/*     */   public final void setOutValue(byte[] outValue) {
/* 193 */     clearOutParam();
/*     */     
/* 195 */     setObjData(outValue, 15);
/* 196 */     setOutDataBound(true);
/*     */   }
/*     */   
/*     */   public final void setInValue(Object inValue, int jType) {
/* 200 */     clearInParam();
/*     */     
/* 202 */     setObjData(inValue, jType);
/* 203 */     setInDataBound(true);
/*     */   }
/*     */   
/*     */   public final void setInValue(Object inValue, int jType, long length) {
/* 207 */     setInValue(inValue, jType);
/* 208 */     setLength(length);
/*     */   }
/*     */   
/*     */   public Object getObjVal() {
/* 212 */     return this.m_val;
/*     */   }
/*     */   
/*     */   public int getObjType() {
/* 216 */     return this.m_jIOType;
/*     */   }
/*     */   
/*     */   public void setPutLobData(int flag) {
/* 220 */     this.m_putLobData = flag;
/*     */   }
/*     */   
/*     */   public int getPutLobData() {
/* 224 */     return this.m_putLobData;
/*     */   }
/*     */   
/*     */   public void setTargetScale(int scale) {
/* 228 */     this.m_targetScale = scale;
/* 229 */     this.m_hasTargetScale = true;
/*     */   }
/*     */   
/*     */   public boolean hasTargetScale() {
/* 233 */     return this.m_hasTargetScale;
/*     */   }
/*     */   
/*     */   public int getTargetScale() {
/* 237 */     return this.m_targetScale;
/*     */   }
/*     */   
/*     */   public void setTargetType(int type) {
/* 241 */     this.m_targetType = type;
/* 242 */     this.m_hasTargetType = true;
/*     */   }
/*     */   
/*     */   public boolean hasTargetType() {
/* 246 */     return this.m_hasTargetType;
/*     */   }
/*     */   
/*     */   public int getTargetType() {
/* 250 */     return this.m_targetType;
/*     */   }
/*     */   
/*     */   public void setRegisterType(int type) {
/* 254 */     this.m_registerType = type;
/* 255 */     this.m_hasRegisterType = true;
/*     */   }
/*     */   
/*     */   public boolean hasRegisterType() {
/* 259 */     return this.m_hasRegisterType;
/*     */   }
/*     */   
/*     */   public int getRegisterType() {
/* 263 */     return this.m_registerType;
/*     */   }
/*     */   
/*     */   public void setRegisterScale(int scale) {
/* 267 */     this.m_registerScale = scale;
/* 268 */     this.m_hasRegisterScale = true;
/*     */   }
/*     */   
/*     */   public boolean hasRegisterScale() {
/* 272 */     return this.m_hasRegisterScale;
/*     */   }
/*     */   
/*     */   public int getRegisterScale() {
/* 276 */     return this.m_registerScale;
/*     */   }
/*     */   
/*     */   public void setInDataBound(boolean bound) {
/* 280 */     this.m_inData_Bound = bound;
/*     */   }
/*     */   
/*     */   public boolean getInDataBound() {
/* 284 */     return this.m_inData_Bound;
/*     */   }
/*     */   
/*     */   public void setOutDataBound(boolean bound) {
/* 288 */     this.m_outData_Bound = bound;
/*     */   }
/*     */   
/*     */   public boolean getOutDataBound() {
/* 292 */     return this.m_outData_Bound;
/*     */   }
/*     */   
/*     */   public void clearInParam() {
/* 296 */     this.m_isReaderOver = false;
/* 297 */     this.m_offset = 0;
/* 298 */     this.m_readerOrInputStream = null;
/* 299 */     this.m_streamConverted = false;
/*     */     
/* 301 */     this.m_length = 0L;
/* 302 */     this.m_hasLength = false;
/*     */     
/* 304 */     this.m_targetScale = 0;
/* 305 */     this.m_hasTargetScale = false;
/*     */     
/* 307 */     this.m_targetType = 0;
/* 308 */     this.m_hasTargetType = false;
/*     */     
/* 310 */     this.m_inData_Bound = false;
/*     */     
/* 312 */     this.m_bsValueTemp = null;
/*     */   }
/*     */   
/*     */   public void clearOutParam() {
/* 316 */     this.m_isReaderOver = false;
/* 317 */     this.m_offset = 0;
/* 318 */     this.m_readerOrInputStream = null;
/* 319 */     this.m_streamConverted = false;
/*     */     
/* 321 */     this.m_outData_Bound = false;
/*     */   }
/*     */   
/*     */   public boolean checkOverWithLength() {
/* 325 */     if (this.m_lengthTmp >= this.m_length) {
/* 326 */       this.m_isReaderOver = true;
/*     */     }
/* 328 */     return this.m_isReaderOver;
/*     */   }
/*     */   
/*     */   public void setLength(long length) {
/* 332 */     this.m_lengthTmp = 0L;
/* 333 */     this.m_length = length;
/* 334 */     this.m_hasLength = true;
/* 335 */     this.m_hasCalcLenTmp = false;
/*     */   }
/*     */   
/*     */   public void calcReadLen(long len_once) {
/* 339 */     this.m_lengthTmp += len_once;
/* 340 */     this.m_hasCalcLenTmp = true;
/*     */   }
/*     */   
/*     */   public boolean hasLength() {
/* 344 */     return this.m_hasLength;
/*     */   }
/*     */   
/*     */   public long leftWithLength() {
/* 348 */     return this.m_length - this.m_lengthTmp;
/*     */   }
/*     */   
/*     */   public long getLength() {
/* 352 */     return this.m_length;
/*     */   }
/*     */   
/*     */   public void setTypeFlag(byte Flag) {
/* 356 */     this.m_typeFlag = Flag;
/* 357 */     this.m_hasTypeFlag = true;
/*     */   }
/*     */   
/*     */   public byte getTypeFlag() {
/* 361 */     return this.m_typeFlag;
/*     */   }
/*     */   
/*     */   public boolean hasTypeFlag() {
/* 365 */     return this.m_hasTypeFlag;
/*     */   }
/*     */   
/*     */   public boolean isNull() {
/* 369 */     return this.m_isNull;
/*     */   }
/*     */   
/*     */   public void setIsNull(boolean isNull) {
/* 373 */     this.m_isNull = isNull;
/*     */   }
/*     */   
/*     */   public void setReaderOrInputStream(Object readerOrIn) {
/* 377 */     this.m_readerOrInputStream = readerOrIn;
/* 378 */     this.m_streamConverted = true;
/*     */   }
/*     */   
/*     */   public boolean streamConverted() {
/* 382 */     return this.m_streamConverted;
/*     */   }
/*     */   
/*     */   public Object getReaderOrInputStream() {
/* 386 */     return this.m_readerOrInputStream;
/*     */   }
/*     */   
/*     */   public void setOffset(int offset) {
/* 390 */     this.m_offset = offset;
/*     */   }
/*     */   
/*     */   public int getOffset() {
/* 394 */     return this.m_offset;
/*     */   }
/*     */   
/*     */   public void setIsReadOver(boolean isOver) {
/* 398 */     this.m_isReaderOver = isOver;
/*     */   }
/*     */   
/*     */   public boolean getIsReadOver() {
/* 402 */     return this.m_isReaderOver;
/*     */   }
/*     */   
/*     */   public byte[] getBytes(ParameterDesc paramDesc, CnvtInfo cnvtInfo, int len) throws SQLException
/*     */   {
/* 407 */     boolean isComplete = false;
/* 408 */     boolean isNeedReadComplete = false;
/*     */     
/*     */ 
/* 411 */     if (len == -1) {
/* 412 */       isNeedReadComplete = true;
/*     */     }
/*     */     
/* 415 */     if ((this.m_isReaderOver) || ((this.m_hasLength) && (checkOverWithLength()))) {
/* 416 */       isComplete = true;
/*     */     }
/* 418 */     byte[] retBs = null;
/*     */     
/* 420 */     if ((this.m_bsValueTemp != null) && ((!isNeedReadComplete) || (isComplete))) {
/* 421 */       retBs = new byte[this.m_bsValueTemp.length];
/* 422 */       System.arraycopy(this.m_bsValueTemp, 0, retBs, 0, this.m_bsValueTemp.length);
/* 423 */       this.m_bsValueTemp = null;
/*     */       
/* 425 */       return retBs;
/*     */     }
/*     */     
/*     */ 
/* 429 */     if (isComplete) {
/* 430 */       return null;
/*     */     }
/*     */     
/* 433 */     retBs = JType2CType.getBytes(this, paramDesc, cnvtInfo, len);
/* 434 */     if ((!this.m_hasCalcLenTmp) && (retBs != null) && (this.m_hasLength)) {
/* 435 */       this.m_lengthTmp += retBs.length;
/*     */     }
/*     */     
/* 438 */     int rslen = retBs != null ? retBs.length : 0;
/* 439 */     int tmpLen = 0;
/*     */     
/* 441 */     if (this.m_bsValueTemp != null) {
/* 442 */       tmpLen = this.m_bsValueTemp.length;
/* 443 */       rslen += tmpLen;
/*     */     }
/*     */     
/*     */ 
/* 447 */     byte[] rsByteArr = new byte[rslen];
/* 448 */     if (this.m_bsValueTemp != null) {
/* 449 */       System.arraycopy(this.m_bsValueTemp, 0, rsByteArr, 0, 
/* 450 */         this.m_bsValueTemp.length);
/* 451 */       this.m_bsValueTemp = null;
/*     */     }
/*     */     
/* 454 */     if (retBs != null) {
/* 455 */       System.arraycopy(retBs, 0, rsByteArr, tmpLen, retBs.length);
/*     */     }
/*     */     
/* 458 */     return rsByteArr;
/*     */   }
/*     */   
/*     */   public byte[] getBytes(ParameterDesc paramDesc, CnvtInfo cnvtInfo) throws SQLException
/*     */   {
/* 463 */     return getBytes(paramDesc, cnvtInfo, -1);
/*     */   }
/*     */   
/*     */   public final Object clone() {
/* 467 */     DmdbParamVal o = null;
/*     */     try {
/* 469 */       o = (DmdbParamVal)super.clone();
/* 470 */       Object value = o.getObjVal();
/* 471 */       if ((value != null) && 
/* 472 */         ((value instanceof byte[]))) {
/* 473 */         int jioType = o.getObjType();
/* 474 */         o.setObjData(((byte[])this.m_val).clone(), jioType);
/*     */       }
/*     */     }
/*     */     catch (CloneNotSupportedException e) {
/* 478 */       e.printStackTrace();
/*     */     }
/* 480 */     return o;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\innerData\DmdbParamVal.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */